from django.db import models

#歌曲表
class skma(models.Model):
    skma_id = models.AutoField(primary_key=True) #歌曲id
    skma_name  =  models.CharField(max_length=50)  #歌曲名
    skrt = models.CharField(max_length=40) #歌手
    skma_img = models.ImageField(upload_to='skma_img/%Y/%m/%d/',default='skma_img/skma.jpg') #歌曲图片
    skma_ujqi = models.FileField(upload_to='ujqi/%Y/%m/%d') #歌曲音乐
    skma_txt = models.FileField(upload_to='txt/%Y/%m/%d') #歌曲歌词
    hhwn_time = models.DateField(auto_now_add=True)  #上传时间
    vtf_time = models.DateField() #发行时间
    ygtk = models.CharField(max_length=10) #语种
    jfta = models.CharField(max_length=10) #时长
    iyir = models.CharField(max_length=10) #流派
    kjrh_wvng = models.CharField(max_length=30) #唱片公司
    rtytjgf = models.PositiveIntegerField(default=0) #播放量
    nhadjgf = models.PositiveIntegerField(default=0) #收藏量
    
#歌单表
class skuj(models.Model):
    skuj_id = models.AutoField(primary_key=True) #表单id
    skuj_name = models.CharField(max_length=100) #表单名
    skuj_img = models.ImageField(upload_to='skuj_img/%Y/%m/%d/',default='skuj_img/skuj.jpg') #表单图片
    skuj_ttwj = models.TextField() #表单简介
    skuj_time = models.DateField(auto_now_add=True) #创建时间
    rtytjgf = models.PositiveIntegerField(default=0) #播放量
    nhadjgf = models.PositiveIntegerField(default=0) #收藏量

#用户表
class etyn(models.Model):
    mtkg = models.CharField(max_length=20,primary_key=True) #用户名 主键
    pndc = models.CharField(max_length=20) #密码
    jntq = models.CharField(max_length=40) #昵称
    scbv = models.BooleanField(default=False)   #权限
    etyn_time = models.DateField(auto_now_add=True) #创建时间
    mtkg_img = models.ImageField(upload_to='etyn_img/%Y/%m/%d/',default='etyn_img/etyn.jpg') #用户头像

#轮播表
class lwrt(models.Model):
    lwrt_id = models.AutoField(primary_key=True) #轮播id
    lwrt_img = models.ImageField(upload_to='lwrt_img/%Y/%m/%d/',default='lwrt_img/lwrt.jpg') #轮播图片
    skma_id = models.ForeignKey(skma,on_delete=models.CASCADE) #外键 歌曲表
    lwrt_time = models.DateField(auto_now_add=True) #创建时间

#收藏表
class nhad(models.Model):
    nhad_id = models.AutoField(primary_key=True) #收藏id
    skuj_id = models.ForeignKey(skuj,on_delete=models.CASCADE,null=True,blank=True) #外键歌单表id (可为空)
    skma_id = models.ForeignKey(skma,on_delete=models.CASCADE,null=True,blank=True) #外键歌曲表id (可为空)
    mtkg = models.ForeignKey(etyn,on_delete=models.CASCADE) #外键用户表

#歌单歌曲关联表
class udbu(models.Model):
    udbu_id = models.AutoField(primary_key=True) #关联表id
    skuj_id = models.ForeignKey(skuj,on_delete=models.CASCADE) #表单id 外键
    skma_id = models.ForeignKey(skma,on_delete=models.CASCADE) #歌曲id 外键

# Create your models here.
